package com.example.client.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Configuration;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author wangxianchen
 * @create 2018-01-26
 * @desc
 */
@Configuration
public class StartedRunner implements CommandLineRunner {

    private static Logger logger = LoggerFactory.getLogger(StartedRunner.class);

    @Value("${spring.application.name:}")
    String appName;
    @Value("${server.port:}")
    String port;

    @Override
    public void run(String... args){
        try {
            InetAddress ia = InetAddress.getLocalHost();//获取本地IP对象
            logger.warn("visit link:  http://"+ia.getHostAddress()+":"+port+"/status");
        } catch (UnknownHostException e) {
            logger.error("获取本机IP失败",e);
        }
    }
}
